/**
 * @author JeffYoung
 * @create 2017年3月23日
 */
package com.scau.service.impl;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import com.scau.dao.IVipDao;
import com.scau.service.IVipService;
import com.scau.util.DateTransform;
import com.scau.vo.Vip;

public class VipServiceImpl implements IVipService{

	private IVipDao vipDao;

	/* (non-Javadoc)
	 * @see com.scau.service.IVipService#addVip(com.scau.vo.Vip)
	 */
	@Override
	public boolean saveVip(Vip vip) {
		// 当前时间由Date->Timestamp
		Date date = new Date();
		DateTransform dt = new DateTransform();
		Timestamp create = dt.dToTimestamp(date);
		vip.setGmtCreate(create);
		// 添加会员时充值金额就是储值卡余额
		vip.setAmount(vip.getRechargeAmount());
		return vipDao.saveVip(vip);
	}

	/* (non-Javadoc)
	 * @see com.scau.service.IVipService#delVip(int)
	 */
	@Override
	public boolean deleteVip(int id) {
		return vipDao.deleteVip(id);
	}

	/* (non-Javadoc)
	 * @see com.scau.service.IVipService#showVips()
	 */
	@Override
	public List<Vip> listVip() {
		return vipDao.listVip();
	}

	/* (non-Javadoc)
	 * @see com.scau.service.IVipService#selectVips(java.lang.String)
	 */
	@Override
	public List<Vip> selectVips(String message) {
		return vipDao.selectVips(message);
	}

	/* (non-Javadoc)
	 * @see com.scau.service.IVipService#updateVip(com.scau.vo.Vip)
	 */
	@Override
	public boolean updateVip(Vip vip) {
		// 当前时间由Date->Timestamp
		Date date = new Date();
		DateTransform dt = new DateTransform();
		Timestamp modified = dt.dToTimestamp(date);
		vip.setGmtModified(modified);
		return vipDao.updateVip(vip);
	}
	
	// 根据ID查一条记录
	public List<Vip> getOneVip(int id){
		return vipDao.getOneVip(id);
	}
	
	// 充值操作
	public List<Vip> rechargeForVip(Vip vip){
		return vipDao.rechargeForVip(vip);
	}
	
	// 修改余额操作
	public List<Vip> changeVipAmount(Vip vip){
		return vipDao.changeVipAmount(vip);
	}
	
	
	// get,set method
	public IVipDao getVipDao() {
		return vipDao;
	}

	public void setVipDao(IVipDao vipDao) {
		this.vipDao = vipDao;
	}
	
}
